var login = function() {
	Ext.QuickTips.init();
	Ext.lib.Ajax.defaultPostHeader += ";charset=utf-8";
	Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
	Ext.form.Field.prototype.msgTarget = 'side';

	var form = new Ext.form.FormPanel({
		renderTo : 'loginpanel',
		defaultType : 'textfield',
		labelAlign : 'left',
		labelWidth : 50,
		buttonAlign:'center',
		width : 300,
		//title : Ext.form.title,
		//region : "center",
		layout : 'form',
		waitMsgTarget : true,
		border : false,
		defaults : {
			allowBlank : false,
			blankText : '该字段不允许为空',
			msgTarget : 'side'
		},
		bodyStyle:'background-color:#2655b7;background-repeat: no-repeat',
		items : [ {
			fieldLabel : Ext.form.name,
			name : 'userForm.petName',
			height:24
		}, {
			fieldLabel : Ext.form.password,
			name : 'userForm.password',
			height:24,
			inputType : 'password'
		}],
		buttons : [ {
			text : Ext.form.login,
			handler : function() {
				if(form.getForm().isValid()) {
					form.getForm().submit({
						url : './bg_bguser_login.htm',
						success : function(f, a) {
							if(a.result.success == 'true') {
								window.location.href = './bg_home_home.htm';
							}
							else {
								com.tietiao.messagebox.warning(a.result.msg);
							}
						},
						waitMsg : '正在提交，请稍等...'
					});
				}
			}
		}/*, {
			text : Ext.form.cancel,
			handler : function() {
				form.getForm().reset();
			}
		}*/ ]
	});
	keydown = function(e)
	{
		var e=e||event;
		var currKey=e.keyCode||e.which||e.charCode;
		if(currKey == 13) {
			if(form.getForm().isValid()) {
				form.getForm().submit({
					url : './bg_bguser_login.htm',
					success : function(f, a) {
						if(a.result.success == 'true') {
								window.location.href = './bg_home_home.htm';
							}
							else {
								com.tietiao.messagebox.warning(a.result.msg);
							}
					},
					waitMsg : '正在提交，请稍等...'
				});
			}
		}
	};
	document.onkeydown =keydown;
};

Ext.onReady(login);
